package com.example.demo.controller;

import com.example.demo.bean.UserBean;
import com.example.demo.request.UserRequest;
import com.example.demo.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/tx")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/login")
    public String show(){
        return "login";
    }

    @PostMapping("/loginIn")
    public UserBean login(@RequestBody UserRequest userRequest){
        UserBean userBean = userService.loginIn(userRequest.getName(),userRequest.getPassword());
        if(userBean!=null){
            return  userBean;
        }else{
            return null;
        }
    }
}
